#include "pm8150.dtsi"
#include "pm7250b.dtsi"
#include "pm8150l.dtsi"
#include <dt-bindings/pinctrl/qcom,pmic-gpio.h>

&pm8150_clkdiv {
	/delete-property/ clocks;
	clocks = <&rpmhcc RPMH_CXO_CLK>;
};

&pm8150_gpios {
	interrupts = <0x0 0xc3 0x0 IRQ_TYPE_NONE>;
	interrupt-names = "pm8150_gpio4";
	qcom,gpios-disallowed = <1 2 3 5 6 7 8 9 10>;
};

&pm8150l_gpios {
	/delete-property/ qcom,gpios-disallowed;
	interrupts = <0x4 0xc0 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc1 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc2 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc3 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc4 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc5 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc6 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc7 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc8 0x0 IRQ_TYPE_NONE>,
			<0x4 0xc9 0x0 IRQ_TYPE_NONE>,
			<0x4 0xca 0x0 IRQ_TYPE_NONE>,
			<0x4 0xcb 0x0 IRQ_TYPE_NONE>;
	interrupt-names = "pm8150l_gpio1", "pm8150l_gpio2",
			"pm8150l_gpio3", "pm8150l_gpio4",
			"pm8150l_gpio5", "pm8150l_gpio6",
			"pm8150l_gpio7", "pm8150l_gpio8",
			"pm8150l_gpio9", "pm8150l_gpio10",
			"pm8150l_gpio11", "pm8150l_gpio12";

	key_vol_up {
		key_vol_up_default: key_vol_up_default {
			pins = "gpio5";
			function = "normal";
			input-enable;
			bias-pull-up;
			power-source = <0>;
		};
	};
};

&pm8150l_clkdiv {
	/delete-property/ clocks;
	clocks = <&rpmhcc RPMH_CXO_CLK>;
};

&pm7250b_vadc {
	#address-cells = <1>;
	#size-cells = <0>;
	pinctrl-names = "default";
	pinctrl-0 = <&bmr_w_therm_default &camera_therm_default>;

	charger_skin_therm@4d {
		reg = <ADC_AMUX_THM1_PU2>;
		label = "charger_skin_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	conn_therm@4f {
		reg = <ADC_AMUX_THM3_PU2>;
		label = "conn_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	bmr_w_therm@53 {
		reg = <ADC_GPIO2_PU2>;
		label = "bmr_w_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	camera_flash_therm@55 {
		reg = <ADC_GPIO4_PU2>;
		label = "camera_flash_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};
};

&pm7250b_gpios {
	bmr_w_therm {
		bmr_w_therm_default: bmr_w_therm_default {
			pins = "gpio12";
			bias-high-impedance;
		};
	};

	camera_therm {
		camera_therm_default: camera_therm_default {
			pins = "gpio8";
			bias-high-impedance;
		};
	};
};

&pm8150_vadc {
	#address-cells = <1>;
	#size-cells = <0>;

	vph_pwr@83 {
		reg = <ADC_VPH_PWR>;
		label = "vph_pwr";
		qcom,pre-scaling = <1 3>;
	};

	vcoin@85 {
		reg = <ADC_VCOIN>;
		label = "vcoin";
		qcom,pre-scaling = <1 3>;
	};

	xo_therm@4c {
		reg = <ADC_XO_THERM_PU2>;
		label = "xo_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	pa_therm1@4d {
		reg = <ADC_AMUX_THM1_PU2>;
		label = "pa_therm1";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	bmr_e_therm@4e {
		reg = <ADC_AMUX_THM2_PU2>;
		label = "bmr_e_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};
};

&pm8150l_vadc {
	#address-cells = <1>;
	#size-cells = <0>;

	vph_pwr@83 {
		reg = <ADC_VPH_PWR>;
		label = "vph_pwr";
		qcom,pre-scaling = <1 3>;
	};

	pa_therm2@4d {
		reg = <ADC_AMUX_THM1_PU2>;
		label = "pa_therm2";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	msm_skin_therm@4e {
		reg = <ADC_AMUX_THM2_PU2>;
		label = "msm_skin_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};

	bmr_n_therm@4f {
		reg = <ADC_AMUX_THM3_PU2>;
		label = "bmr_n_therm";
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
		qcom,pre-scaling = <1 1>;
	};
};

&pm7250b_adc_tm {
	#address-cells = <1>;
	#size-cells = <0>;
	io-channels = <&pm7250b_vadc ADC_AMUX_THM1_PU2>,
			<&pm7250b_vadc ADC_GPIO2_PU2>,
			<&pm7250b_vadc ADC_GPIO4_PU2>;

	/* Channel nodes */
	charger_skin_therm@4d {
		reg = <ADC_AMUX_THM1_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	bmr_w_therm@53 {
		reg = <ADC_GPIO2_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	camera_flash_therm@55 {
		reg = <ADC_GPIO4_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};
};

&pm8150_adc_tm {
	#address-cells = <1>;
	#size-cells = <0>;
	io-channels = <&pm8150_vadc ADC_XO_THERM_PU2>,
			<&pm8150_vadc ADC_AMUX_THM1_PU2>,
			<&pm8150_vadc ADC_AMUX_THM2_PU2>;

	/* Channel nodes */
	xo_therm@4c {
		reg = <ADC_XO_THERM_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	pa_therm1@4d {
		reg = <ADC_AMUX_THM1_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	bmr_e_therm@4e {
		reg = <ADC_AMUX_THM2_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};
};

&pm8150l_adc_tm {
	#address-cells = <1>;
	#size-cells = <0>;
	io-channels = <&pm8150l_vadc ADC_AMUX_THM1_PU2>,
			<&pm8150l_vadc ADC_AMUX_THM2_PU2>,
			<&pm8150l_vadc ADC_AMUX_THM3_PU2>;

	/* Channel nodes */
	pa_therm2@4d {
		reg = <ADC_AMUX_THM1_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	msm_skin_therm1@4e {
		reg = <ADC_AMUX_THM2_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};

	bmr_n_therm@4f {
		reg = <ADC_AMUX_THM3_PU2>;
		qcom,ratiometric;
		qcom,hw-settle-time = <200>;
	};
};

&thermal_zones {
	charger-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm7250b_adc_tm ADC_AMUX_THM1_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	mmw-pa2-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm7250b_adc_tm ADC_GPIO2_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	camera-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm7250b_adc_tm ADC_GPIO4_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	xo-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm8150_adc_tm ADC_XO_THERM_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	pa-therm1-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm8150_adc_tm ADC_AMUX_THM1_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	mmw-pa3-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm8150_adc_tm ADC_AMUX_THM2_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	pa-therm2-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm8150l_adc_tm ADC_AMUX_THM1_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	msm-s-therm-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm8150l_adc_tm ADC_AMUX_THM2_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};

	mmw-pa1-usr {
		polling-delay-passive = <0>;
		polling-delay = <0>;
		thermal-governor = "user_space";
		thermal-sensors = <&pm8150l_adc_tm ADC_AMUX_THM3_PU2>;
		wake-capable-sensor;
		trips {
			active-config0 {
				temperature = <125000>;
				hysteresis = <1000>;
				type = "passive";
			};
		};
	};
};

&pm7250b_charger {
	dpdm-supply = <&usb2_phy0>;

	smb5_vbus: qcom,smb5-vbus {
		regulator-name = "smb5-vbus";
	};

	smb5_vconn: qcom,smb5-vconn {
		regulator-name = "smb5-vconn";
	};
};

&pm8150l_gpios {
	eldo13_pin {
		usb_eldo13:gpio@cb00 {
			pins = "gpio12";
			function = "normal";
			qcom,drive-strength = <2>;
			power-source = <0>;
			bias-disable;
			output-high;
		};
	};
};

&pm7250b_pdphy {
	vdd-pdphy-supply = <&pm8150_l2>;
	vbus-supply = <&smb5_vbus>;
	vconn-supply = <&smb5_vconn>;
};

&usb0 {
	extcon = <&pm7250b_pdphy>, <&pm7250b_charger>, <&eud>;
};

&usb_qmp_dp_phy {
	extcon = <&pm7250b_pdphy>;
};
